package com.timoon.testng.demo;
import java.math.BigInteger;

import javax.swing.*;
public class A {

	public static void main(String[] args) {
		String s1=JOptionPane.showInputDialog("请输入需要转换的数是几进制数");
		String s2=JOptionPane.showInputDialog("请输入需要转换的数");
		String s3=JOptionPane.showInputDialog("请输入需要转换为几进制数");
		int j1=Integer.parseInt(s1);
		int j3=Integer.parseInt(s3);
		System.out.println("输入的是"+s2+"("+j1+")"+" ——"+j3);
		
		if(j3==10){
			if(j1==2){
				BigInteger src = new BigInteger(s2,2);
				System.out.println("结果是"+src.toString());
			}else{
				System.out.println("结果是"+s2);
			}
		}
		
		if(j3==2){
			if(j1==2){
				System.out.println("结果是"+s2);
			}else{
				BigInteger src = new BigInteger(s2);
				System.out.println("结果是"+src.toString(2));
			}
		}
	}

}
